<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<%@ include file="/common/plateform/include/common-base.jsp"%>
	<title>接口参数管理</title>
</head>

<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">

  <!-- top start -->
  <%@include file="/common/plateform/top.jsp" %>
  <!-- top end -->
  <!-- left start -->
  <%@include file="/common/plateform/left-project.jsp" %>
  <!-- left end-->
f
  <div class="content-wrapper">
  
	<section class="content">
      <div class="row">
        <div class="col-xs-12">
            <!--搜索  start -->
          <div class="box box-info">
             <!--搜索title  start --> 
	          <div class="box-header with-border">
                 <h3 class="box-title"><i class="fa fa-search"></i>接口查询搜索</h3>
                 <div class="box-tools pull-right">
	                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
	                </button>
                 </div>
              </div>
            <!--搜索title  end --> 
            <div class="box-body">
			  <form id="searchForm" class="form-horizontal" action="javascript:;">
				<input type="hidden" name="pageName" value="sys-param-manager"/>
				<input type="hidden" name="formName" value="searchForm">
				<input id="searchForm_sysName" type="hidden" name="sysParamManager.wi_sysName" value="">

<%--				<input type="hidden" name="sysParamManager.delStatus" value="F">--%>
				<input type="hidden" name="orderBy" value="create_time desc,page_name desc,form_name asc">

				 <table class="table">
					 <tbody>
					 	<tr>
							<td class="text-right w150"><label class="control-label" >pageName：</label></td>
							<td class="w350"><input type="text" class="form-control clean"  name="sysParamManager.wl_pageName" value="" /></td>
							<td class="text-right w150"><label class="control-label" >formName：</label></td>
							<td><input type="text" class="form-control clean"  name="sysParamManager.wl_formName" value="" /></td>
						</tr>
						<tr>
							<td class="text-right"><label class="control-label" >增删改：</label></td>
							<td><input type="text" class="form-control clean"  name="sysParamManager.wl_modelTypes" value="" /></td>
							<td class="text-right"><label class="control-label" >插件组合：</label></td>
							<td>
								<select id="searchForm_rulesName"
										name="sysParamManager.wl_rulesName" class="form-control clean"
										data-temp-obj="rulesName" data-page-name="sysPluginGroup-list"
										data-form-name="dictForm"
										data-dict-code="dymicSql" data-dict-cate=""
										data-colmun="{value:'rulesCode',text:'rulesCode,rulesRemark',other:'rulesId'}"
										data-type-tag="select" data-def="">
								</select>
							</td>
						</tr>
					 </tbody>
				 </table>
				<center>
				   <div class="box-footer clearfix">
				      <button type="button" class="btn btn-success" onclick="getTableData();"><i class="fa fa-search"></i> 查询</button>&nbsp;
				<button  type="button" class="btn btn-warning" onclick="mytools.cleanData('#searchForm');">重置 </button>&nbsp;
				<button  data-step="3" data-intro="增加接口完成后，点此进行数据同步。"  type="button" class="btn btn-danger" onclick="loadCache();">数据同步 </button>
			    <button  data-step="3" data-intro="根据查询条件生成sql语句"  type="button" class="btn btn-default" onclick="createSql();">生成sql语句 </button>

				   </div>
				</center>
			  </form>
            </div>
	     </div>
	     <!-- 搜索 end -->
        
        
        <div class="box box-success">
            <!--列表title  start --> 
	          <div class="box-header with-border">
				  <h3 class="box-title"> 接口管理列表 [<span id="span-sysname-text"></span>] [共计<span id="dataListTotalCount">0</span>条数据]
                 　　<button data-step="1" data-intro="点此按钮，在弹框内增加接口配置。" onclick="showMonacoPage();" class="btn btn-success" type="button"><i class="fa fa-plus-circle"></i> 增加 </button>
                 </h3>
                 <div class="box-tools pull-right">
	                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
	                </button>
                 </div>
              </div>
            <!--列表title  end --> 
             <div class="box-body">
              <table id="dataList" class="table table-bordered table-hover" >
               <thead class="bg-success">
                <tr>
                  <th width="200px">pageName</th>
                  <th width="120px">formName</th>
                  <th>增删改/插件组合</th>
                  <th>所属系统</th>
                  <th width="200px">操作</th>
                </tr>
                </thead>
                <tbody id="dataList-body">
                </tbody>
              </table>
              <center>
    	  		<ul id="dataList-page"></ul>
              </center>
            </div>
         </div>
        </div>
      </div>
  
    <!--
    <div class="modal fade" id="my_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width:900px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							&times;
						</button>
						<h4 class="modal-title">
							<font color="red">参数添加/修改</font>&nbsp;
						</h4>
					</div>
					<div class="modal-body">
						<form class="form-horizontal" role="form" id="submitForm" action="javascript:;">
							<input type="hidden" name="doCode" value="dymicSql"/>
							<input type="hidden" id="modelTypes" name="modelTypes" value="i_sysParamManager"/>
							<input type="hidden" id="w_infoId" name="sysParamManager.w_infoId" value=""/>
							<input type="hidden" id="formToken" name="formToken"  value="${formToken}"/>
							<input id="delStatus" name="sysParamManager.delStatus" type="hidden" value="F" />
					        <div class="box-body" id="submitFormData">
					          <div class="nav-tabs-custom">
					            <div class="tab-content">
					              <div class="tab-pane active" id="tab_1">
					              <div class="form-group">
						                  <label class="col-sm-2 control-label" >所属系统</label>
						                  <div class="col-sm-10">

							                  <select id="submitForm_sysName"  readonly="readonly"
															name="sysParamManager.sysName" class="form-control clean"
															data-temp-obj="sysName"  data-name="sysParamManager.sysName"
															data-dict-code="dymicSql" data-dict-cate="s_uctSys"
															data-colmun="{value:'sysEname',text:'sysCname',other:''}"
															data-type-tag="select" data-def="">
												</select>
										  </div>
							        </div>


								  <div class="form-group">
									  <label class="col-sm-2 control-label" >增删改查接口</label>
									  <div class="col-sm-8">
										  <input type="text" id="submitForm_modelTypes" readonly="readonly" class="form-control clean" name="sysParamManager.modelTypes" data-name="sysParamManager.modelTypes" placeholder="请点击右侧按钮选择接口类型"/>
									  </div>
									  <div class="col-sm-2">
										  <button type="button" onclick="showObjNameTable()" class="btn btn-primary btn-sm"><i class="fa fa-search-plus"></i> 选择接口类型</button>
									  </div>
								  </div>

					                <div class="form-group">
					                  <label class="col-sm-2 control-label">pageName</label>
					                  <div class="col-sm-4">
					                    <input type="text" id="pageName" name="sysParamManager.pageName" data-name="sysParamManager.pageName" class="form-control clean" data-bv-notempty="true" data-bv-notempty-message="此项不能为空" placeholder="必填项" maxlength="30">
					                  </div>
					                  <label class="col-sm-2 control-label" >form名称</label>
					                  <div class="col-sm-4">
					                    <input type="text" id="formName" name="sysParamManager.formName" data-name="sysParamManager.formName" class="form-control clean" data-bv-notempty="true" data-bv-notempty-message="此项不能为空" placeholder="必填项" maxlength="30">
					                  </div>
					                </div>


					                <div class="form-group resultName" style="display: none;">
					                  <label class="col-sm-2 control-label" >返回类型</label>
					                  <div class="col-sm-10" >
					                  	<select id="resultName" class="form-control" name="sysParamManager.resultName">
					                  	</select>
					                  </div>
					                </div>

					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >关联关系</label>
					                  <div class="col-sm-10">
					                  	<textarea id="relation"  class="form-control clean" name="sysParamManager.relation" data-name="sysParamManager.relation" rows="2" cols="50"></textarea>
					                  	<textarea id="s_relation" class="form-control clean"  name="sysParamManager.s_relation" data-name="sysParamManager.relation" rows="2" cols="50" style="display: none"></textarea>
					                  </div>
					                </div>

					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >返回列</label>
					                  <div class="col-sm-10">
					                  	<textarea id="resultColumn" class="form-control clean" data-name="sysParamManager.resultColumn" name="sysParamManager.resultColumn" rows="2" cols="50"></textarea>
					                  	<textarea id="s_resultColumn" class="form-control clean" data-name="sysParamManager.resultColumn" name="sysParamManager.s_resultColumn" rows="2" cols="50" style="display: none"></textarea>
					                  </div>
					                </div>
					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >拦截方式</label>
					                  <div class="col-sm-10">
					                  	<select id="evelName" class="form-control clean" name="sysParamManager.evelName">
					                  		<option value="beforMethodKey" selected="selected">方法前拦截</option>
					                  		<option value="afterMethodKey">方法后拦截</option>
					                  	</select>
					                  </div>
					                </div>
					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >插件组合</label>
					                  <div class="col-sm-10">
					                  	<select id="submitForm_rulesName"
													name="sysParamManager.rulesName" class="form-control clean"
													data-temp-obj="rulesName" data-name="sysParamManager.rulesName"
													data-dict-code="dymicSql" data-dict-cate="s_sysPluginGroup"
													data-colmun="{value:'rulesCode',text:'rulesCode,rulesRemark',other:'rulesId'}"
													data-type-tag="select" data-def="">
										</select>
					                  </div>
					                </div>

					              </div>					             
					            </div>
					          </div>
					        </div>
			                <div class="box-footer">
				                <button type="button" class="btn btn-success pull-left" onclick="mytools.closeModal('my_modal');">取消</button>
				                <button type="button" class="btn btn-danger pull-right" onclick="save('submitForm');">提 交</button>
				            </div>
						</form>
					</div>

					
					
					
				</div>
			</div>
</div>  
 -->

    
 <!-- 授权 -->
<div class="modal fade" id="act_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog" style="width:900px;">
				<div class="modal-content" id="user-acts">
				   <div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4 class="modal-title"><font color="red">参数授权</font>&nbsp;</h4>
					</div>
					<div class="modal-body">
						<form class="form-horizontal" role="form" id="actIusForm">
						  <input name="iusId" id="act-iusId" type="hidden">
						<!-- Custom Tabs -->
							<div class="nav-tabs-custom">
								<div class="tab-content">
									<div class="tab-pane active" id="tab_2">
										<table id="ius-actsTable" class="table table-bordered table-hover" >
											<thead>
											<tr><th>资源名</th>
												<th>资源英文全称</th><th>操作</th>
											</tr>
											</thead>
											<tbody id="iusActsList"></tbody>
										</table>
									</div>
								</div>
							</div>
					    </form>
					</div>
				</div>
		</div>
</div>


		<div class="modal fade" id="sql_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog" style="width:1200px;">
				<div class="modal-content" >
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4 class="modal-title"><font color="red">sql</font>&nbsp;</h4>
					</div>
					<div class="modal-body">
						<form class="form-horizontal" role="form">
							<!-- Custom Tabs -->
							<div class="nav-tabs-custom">
								<div class="tab-content">
									<div class="container" style="word-wrap:break-word;width: 100%" id="sqlDiv"></div>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>


		<div win-title="接口测试窗口" class="modal fade" id="my_modal_testIus" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog" style="width:80%;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">接口测试</font> 
						</h4>
					</div>

					<div class="modal-body">

						<div class="nav-tabs-custom">

							<!-- tab content start -->
							<div class="tab-content">

								<div class="tab-pane active">
									<form class="form-horizontal addFormBody" role="form" id="iusCheckForm" action="javascript:void(0)">

										<table class="table table-bordered bordercolor">
											<tbody>
											<tr>
												<td class="active" align="right"><label class="form-control-static">pageName：</label>
												</td>
												<td>
													<div class="form-group"><input id="ius-pageName"
																				   name="pageName"
																				   class="form-control"
																				   readonly="readonly"/></div>
												</td>
												<td class="active" align="right"><label class="form-control-static">formName：</label>
												</td>
												<td>
													<div class="form-group"><input id="ius-formName"
																				   name="formName"
																				   class="form-control"
																				   readonly="readonly"/></div>
												</td>
											</tr>
											<tr>
												<td class="active" align="right"><label class="form-control-static">操作对象：</label>
												</td>
												<td>
													<div class="form-group"><input id="ius-modelTypes"
																				   class="form-control"
																				   readonly="readonly"/></div>
												</td>
												<td class="active" align="right"><label class="form-control-static">操作类型：</label>
												</td>
												<td>
													<div id="div-model-types-span-radio" class="form-group form-control-static">
														<span><input type="radio" name="radio-modelTypes" value="s" disabled="disabled"/> 查询 &nbsp;&nbsp;</span>
														<span><input type="radio" name="radio-modelTypes" value="i" disabled="disabled"/> 增加 &nbsp;&nbsp;</span>
														<span><input type="radio" name="radio-modelTypes" value="d" disabled="disabled"/> 删除 &nbsp;&nbsp;</span>
														<span><input type="radio" name="radio-modelTypes" value="u" disabled="disabled"/> 修改 &nbsp;&nbsp;</span>
													</div>
												</td>
											</tr>
											<tr>
												<td class="active" align="right"><label class="form-control-static">请求地址：</label>
												</td>
												<td>
													<div class="form-group form-control-static" id="ius-request-url">
													</div>
												</td>
												<td class="active" align="right"><label class="form-control-static">请求方式：</label>
												</td>
												<td>
													<div class="col-lg-6 form-group form-control-static" id="ius-request-type">
													</div>
													<div class="col-lg-6 form-group">
														<button class="btn btn-danger pull-right" type="button" onclick="doSubmitIusCheck();"> 发送测试请求 </button>
													</div>
												</td>
											</tr>
											<tr>
												<td class="active" align="right"><label class="form-control-static">请求参数：</label>
												</td>
												<td colspan="3">
													<div class="form-group">
														<input id="ius-param-data" class="form-control" />
														<span class="f12">多个参数之间用&符号分开</span>
													</div>
												</td>
											</tr>
											<tr>
												<td colspan="4">
													<div class="form-group">
														<textarea class="form-control clean" id="ius-request-result" rows="6" cols="50" placeholder="显示返回的结果" ></textarea>
													</div>
												</td>
											</tr>
											</tbody>
										</table>

									</form>
								</div>

							</div>
							<!-- tab content end -->
						</div>

					</div>
				</div>
				<!-- /.modal-content -->
			</div>
		</div>

<script type="text/template" id="dataList-template">
		<? for ( var i = 0; i < rows.length; i++) {?>
			<tr <?if('${param.formName}'==rows[i].formName){?> class="bg-danger"<?}?> >
				<td style="display:none;"><?=rows[i].sysParamManager.infoId?></td>
				<td>
					<?=rows[i].sysParamManager.pageName?>
				</td>
				<td>
					<?=rows[i].sysParamManager.formName?>
				</td>
				<td>
					<div class="fx12"><?=strUtil.subStr(rows[i].sysParamManager.modelTypes,40)?> </div>
					<?if(rows[i].sysParamManager.rulesName){?><div class="red"><?=dictListMap["sysPluginGroup-list-dictForm"][strUtil.doNull(rows[i].sysParamManager.rulesName,"-")]?></div><?}?>
				</td>
				<td>
					<?=rows[i].sysParamManager.sysName?>
				</td>
				<td <?if(i==0){?>data-step="2" data-intro="每个接口都提供了其他操作！"<?}?>>
					<?if(${param.flag=='T'}){?>
						<button type="button" pagename="<?=rows[i].sysParamManager.pageName?>" formname="<?=rows[i].sysParamManager.formName?>" modeltypes="<?=rows[i].sysParamManager.modelTypes?>" infoid="<?=rows[i].sysParamManager.infoId?>" rulesname="<?=strUtil.doNull(rows[i].sysParamManager.rulesName,'')?>" class="btn btn-danger btn-xs" onclick="checkIusPre(this);"><i class="fa fa-check-square-o"></i> 选用</button>&nbsp;
					<?}?>
					<%--<button type="button" class="btn btn-warning btn-xs" onclick="toLoad('<?=rows[i].sysParamManager.infoId?>','edit');">修改</button> --%>
					<button type="button" class="btn btn-warning btn-xs" onclick="showMonacoPage('<?=rows[i].sysParamManager.infoId?>');">修改</button>&nbsp;
					<button type="button" class="btn btn-danger btn-xs" onclick="toDele('<?=rows[i].sysParamManager.infoId?>');">删除</button>&nbsp;
					<button type="button" class="btn btn-primary btn-xs" onclick="openIusCheck('<?=rows[i].sysParamManager.pageName?>','<?=rows[i].sysParamManager.formName?>','<?=rows[i].sysParamManager.modelTypes?>')">测试</button>
					<?if(!${param.flag=='T'}){?>
					 <button type="button" class="btn btn-success btn-xs" onclick="setActIus('<?=rows[i].sysParamManager.infoId?>');">权限设置</button>
					<?}?>
				</td>
			</tr>
		<?}?>
</script>

<script type="text/template" id="iusActListData">
	  		<? for ( var i = 0; i < rows.length; i++) {?>
				<tr id="role_<?=rows[i].actId?>"  roleFatherId=<?=rows[i].fatherId?>>
					<th style="display:none;"><?=rows[i].actId?></th>
					<th style="display:none;"><?=rows[i].actCname?></th>
					<th style="display:none;"><?=rows[i].fatherId?></th>
					<td><?if(rows[i].subCount>0){?>
							<i class="fa fa-folder" onclick="getChildIusActsData('<?=rows[i].actId?>','<?=rows[i].fullEname?>',this);">&nbsp;<?=rows[i].actCname?></i>
						<?} else{?>		
							<i class="fa fa-file"></i>&nbsp;<?=rows[i].actCname?>
						<?}?></td>
					<td><?=rows[i].fullEname?></td>
					<td><?if("T"==rows[i].hasGive){?>
                        <i class="fa fa-check fa-2x" ondblclick="giveIus(this,'<?=rows[i].actId?>','<?=rows[i].fullEname?>');"></i>
                       <?}else{?>
                       <i class="fa fa-close fa-2x" ondblclick="giveIus(this,'<?=rows[i].actId?>','<?=rows[i].fullEname?>');"></i>
                       <?}?></td>
				</tr>
     		<?}?>
	</script>    
    
    
  <script>
var clickMenu = "sysParamManager-list";
var id,myPage,dataListId,searchFormId,isShowLog,tableSort,tableId;
myPage = 10;
dataListId = "dataList";
searchFormId = "searchForm";
tableSort = "sysParamManager";
tableId = "infoId";
isShowLog = true;
var sysNameData={};
var ruleNameData={};
var index_load = layer.load(1, {shade: false});
var defSysEname = strUtil.doNull(strUtil.getLocalStorage("sysEname"), "");
var thisObjNameAll="";
$("#span-sysname-text").text(defSysEname+"-"+strUtil.getLocalStorage("sysCname"));
$("#searchForm_rulesName").attr("data-condition","sysPluginGroup.w_delStatus=F&sysPluginGroup.wi_sysName="+defSysEname);
//$("#searchForm_sysName").attr("data-condition","uctSys.w_sysEname="+defSysEname);
//$("#submitForm_sysName").attr("data-condition","uctSys.w_sysEname="+defSysEname);
//$("#submitForm_rulesName").attr("data-condition","sysPluginGroup.w_delStatus=F&sysPluginGroup.wi_sysName="+defSysEname);

var dictListMap = DictUtil.initDictAndDymic();
$(function () {
	$("#submitForm_modelTypes").bind("input propertychange", function() {
		loadResultName();
	});
    $("#searchForm_sysName").val(defSysEname+",plateform");

	getTableData();//该方法找不到
	//2、控制是否启用token
	//setToken();


 });
////读取（查询、编辑）数据
//function toLoad(id,type){
//    var paramLoadData = {"sysParamManager.w_infoId":id,"modelTypes":"s_"+tableSort};
//    loadObj(type,paramLoadData);
//}
function toDele(id){
	var index_submit = layer.confirm('您确定要删除信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		var paramLoadData = {"pageName":"sys-param-manager","formName":"delForm","sysParamManager.w_infoId":id};
            var index_load = layer.load(1, {shade: false});
            $.ajax({
                type:"post",
                url:common_submit_url,
                data: paramLoadData,
                dataType:"json",
                success: function(myData){
                    layer.close(index_load);
                    var result = myData.flag;
                    if(result=="T"){
                        layer.alert("删除操作成功");
                        refresh();
                    }
                }
            });
        });
}

//打开添加页面
//function toAdd(){
//	mytools.cleanData('submitFormData');//情况模态窗口内数据
//	$("#w_"+tableId).val("");
//	$(".datepicker").val("");
//	$("#modelTypes").val("i_"+tableSort);
//	 $('#my_modal').modal('show');
//
//	$("#s_relation").attr("disabled",true);
//	$("#s_relation").hide();
//	$("#relation").show();
//	$("#relation").attr("disabled",false);
//
//	$("#s_resultColumn").attr("disabled",true);
//	$("#s_resultColumn").hide();
//	$("#resultColumn").show();
//	$("#resultColumn").attr("disabled",false);
//
//    $("#submitForm_sysName").val(defSysEname);
//	$("#submitForm_rulesName").attr("name","sysParamManager.rulesName");
//
//}
//反显数据
//function showData(type,myData){
//	//console.log(myData);
//	if("view"==type){
//		FormUtil.loadView("sysParamManager", myData);
//		$("#my_modal_view").modal("show");
//
//	}else if("edit"==type){
//		$("#submitForm_rulesName").attr("name","sysParamManager.s_rulesName");
//		//FormUtil.fillData("#submitForm", myData,"id");
//		$("#submitForm_modelTypes").val(myData.modelTypes);
//		FormUtil.loadView("sysParamManager", myData);
//		loadResultName();
//		DictUtil.checkSelectDict("#resultName",myData.resultName);
//
//
//		$("#relation").attr("disabled",true);
//		$("#relation").hide();
//		$("#s_relation").show();
//		$("#s_relation").attr("disabled",false);
//
//		$("#resultColumn").attr("disabled",true);
//		$("#resultColumn").hide();
//		$("#s_resultColumn").show();
//		$("#s_resultColumn").attr("disabled",false);
//
//
//		$("#rulesName").attr("disabled",true);
//		$("#rulesName").hide();
//		$("#s_rulesName").show();
//		$("#s_rulesName").attr("disabled",false);
//
//		$("#evelName").val(myData.evelName);
//		$("#modelTypes").val("u_"+tableSort);
//		$("#w_"+tableId).val(myData.infoId);
//		$("#my_modal").modal("show");
//	}
//}
//function subStrPlugin(str){
//	var ssp = str.split(".");
//	return ssp[0]+"....."+ssp[4]+"."+ssp[5];
//}
function loadCache(){
	var index_load = layer.msg("数据同步进行中。。。",{time:false});
	$.ajax({
	    type:'post',
	    //url:'${ctx}/sendPage/loadCache',
        url: common_cache_url+"init",
        data:{"pageName":"sys-param-manager","formName":"initiCacheForm"},
        dataType:'json',
	    success: function(myData){
            console.log("sysParamManager.initiCacheForm",myData);
	    	layer.close(index_load);
	    	layer.alert(myData.msg);
	  	}
	});	
}
//设置模态框隐藏事件钩子  
$( '#my_modal' ).on( 'hide.bs.modal' ,function(e){  
	mytools.cleanData('#submitFormData');
}); 

function setActIus(iusId){
	getIusListData(iusId,'0');
	$('#act_modal').modal('show');
}

var _para_iusId;
function getIusListData(iusId,fatherId){
	_para_iusId=iusId;
	$("#act-iusId").val(id);
	$.ajax({ type:'post', url:ctx+'/res/uct/admin/roleActData?ifIus=true&iusId='+iusId+"&id="+fatherId,
		   data:$('#actFrom').serialize(), dataType:'json',
		   success: function(myData){
		    var myDatas = new Object();
		    myDatas.rows = myData;
			var data = baidu.template('iusActListData',eval(myDatas));  
			$("#iusActsList").html(data);
		   }
	 });	
  } 
function giveIus(obj,actId,actFullEname){
	//alert(actFullEname);
   var flag = "add";
   var paramLoadData = {flag:flag,'uctActIus.actId':actId,'uctActIus.actEname':actFullEname,'uctActIus.iusId':_para_iusId,objType:'uctActIus'};
   if ($(obj).hasClass('fa-check')) {
         flag = "del";
      paramLoadData = {flag:flag,'uctActIus.w_actId':actId,'uctActIus.w_actEname':actFullEname,'uctActIus.w_iusId':_para_iusId,objType:'uctActIus'};
   }
   $.ajax({type: "post",
		url: ctx+"/res/uct/admin/authorizeAct?ifIus=true",
		data:paramLoadData,
		success: function(data, textStatus){
			if($(obj).hasClass('fa-check')){
				$(obj).attr("class","fa fa-close fa-2x");
			}else{
				$(obj).attr("class","fa fa-check fa-2x");
			}
		}
   });
}

function getChildIusActsData(actId,treeLevel,obj){
var count =0;
var ss = treeLevel.split("/");
count = ss.length-1;
	$.ajax({
		   type:'post',
		   url:ctx+'/res/uct/admin/roleActData',
		   data:{'id':actId,'iusId':_para_iusId,ifIus:'true'},
		   dataType:'json',
		   success: function(myData){
		    var myDatas = new Object();
		    myDatas.rows = myData;
			var data = baidu.template('iusActListData',myDatas); 
			if($(obj).hasClass("fa-folder-open")){
				$(obj).attr("class","fa fa-folder");
				delRoleActsChiled(actId);
			}else{
				$(obj).attr("class","fa fa-folder-open");
				$("#role_"+actId).after(data);
				 $("[roleFatherId='"+actId+"']").each(function(i){
					var thisObj = $(this);
					var pd = "10px 20px 10px ";
					var num = pd+(count*20)+"px";
					$(thisObj).find("td").eq(0).css("padding",num);
				 });
			 }
		   }
		});	
  } 
  function delRoleActsChiled(id){
	  $("[roleFatherId='"+id+"']").each(function(i){
			 var thisObj = $(this);
			 $(thisObj).remove();
			 var id = thisObj.attr("id");
			 delRoleActsChiled(id);
		 });
  }
  
//加载列表数据
  function getTableData(){
      var index_load = layer.load(1, {shade: false});
  	$.ajax({
  		   type:'get',
  		   url:common_list_url,
  		   data:$("#"+searchFormId).serialize()+getCurrentPage(common_list_url+"?"+$("#"+searchFormId).serialize(),myPage),
  		   dataType:'json',
  		   success: function(myData){
  		       $("#dataListTotalCount").text(myData.total);
				console.log(myData);
				var data = baidu.template(dataListId+"-template",eval(myData));
				$("#"+dataListId+"-body").html(data);
				  var option= {
						   ele:$("#"+dataListId+"-page")[0],
						   total:myData.total,
						   fn:getTableData,
						   url:common_list_url+"?"+$("#"+searchFormId).serialize()
					   }
  				generatePages(option);

               // layer.closeAll();
               layer.close(index_load);

               initGuideIntroJs();

  		   }
  		});	
    }
    
  /**
   * 表单数据提交
   * @param formId
   */
//  function save(formId){
//      if(strUtil.isNull($("#submitForm_modelTypes").val())){
//          layer.alert("请先选择接口类型！");
//          return;
//	  }
//      var validate = $('#' + formId).data('bootstrapValidator').validate();
//      if (!validate.isValid()) { //如果校验不通过就返回
//          return;
//      }
//  	var index_submit = layer.confirm('您确定要提交信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
//  	, function(){
//  		layer.close(index_submit);
//  		$.ajax({
//  		    type:"post",
//  		    url:common_submit_url,
//  		    data:$("#"+formId).serialize(),
//  		    dataType:"json",
//  		    success: function(myData){
//  		    	//console.log(myData);
//  		    	if(myData.flag=="T"){
//  		    		layer.alert("数据保存成功");
//  		    		$("#my_modal").modal("hide");
//  		    	}else{
//  		    		layer.alert(myData.msg);
//  		    	}
//  		    	refresh();
//  		  	}
//  		});
//  	});
//  }
//


function refresh(){
	getTableData();
}


function setToken(){
	$.ajax({
	    type:'get',
	    url:ctx+'/sendPage/token?token=true',
	    dataType:'text',
	    success: function(myData){
	    	//console.log(myData);
			 $('#formToken').val(myData);
	  	}
	});	
}


//获取对象值
//function loadObj(type,paramData){
//	$.ajax({
//	    type:'get',
//	   	url:common_info_url+"?doCode=dymicSql",
//	    data: paramData,
//	    async:false,
//	    dataType:"json",
//	    success: function(myData){
//	    	showData(type,myData);
//	  	}
//	});
//}

function loadResultName(){
	  var modelTypes = $("#submitForm_modelTypes").val();
	  if(modelTypes.indexOf("s_")>=0){
		  if(modelTypes.indexOf(",")>=0){
			  $("#resultName").html("<option value='T'>实体.属性名</option>");
		  }else{
		  	  $("#resultName").html("<option value='T'>实体.属性名</option><option value='F'>属性名</option>");
		  }
		  $(".resultName").show();
	  }else{
		  $(".resultName").hide();
	  }
	  
}

function openIusCheck(pageName,formName,modelTypes){
    $("#my_modal_testIus").modal("show");
	$("#ius-pageName").val(pageName);
    $("#ius-formName").val(formName);

    $("#ius-modelTypes").val(modelTypes);
//    var typeFlag = modelTypes.split(",")[0].split("_")[0];//以第一个为准
    var typeFlag = modelTypes.split(",")[0].split("_")[0].substr(0,1);//以第一个为准
    $("#div-model-types-span-radio").find("span").removeClass("red fb");
    $("input[type='radio'][name='radio-modelTypes'][value='"+typeFlag+"']").prop('checked',true).parent().addClass("red fb");

    var reqUrl = common_list_url;
    var reqType = "get";
    if("s"==typeFlag){
        reqUrl = common_list_url;
        reqType = "get";
	}else {
        reqUrl = common_submit_url;
        reqType = "post";
	}

	var objssArrays = modelTypes.split(",");
    var defValParamMap = {};
    if(objssArrays.length>1){
        for(var a=0;a<objssArrays.length;a++){
            if(objssArrays[a].indexOf('ib_')>-1){
                var objName = objssArrays[a].split('ib_')[1];
                defValParamMap["ifBatch"]= "T";
                defValParamMap[objName+".splitAttr"]= "";
            }
        }
	}
	var defValParamStr = "";
    for(var key in defValParamMap){
        defValParamStr+=key+"="+defValParamMap[key]+"&";
    }
	if(!strUtil.isNull(defValParamStr)){
        defValParamStr = defValParamStr.substring(0,defValParamStr.length-1);
	}


	$("#ius-request-url").text(reqUrl);
    $("#ius-request-type").text(reqType);
    $("#ius-request-result").val("");
    $("#ius-param-data").val(defValParamStr);
}

//提交操作请求
function doSubmitIusCheck(){
    $("#ius-request-result").val("");
    var reqUrl = $("#ius-request-url").text();
    var reqType = $("#ius-request-type").text();
    var otherParam = $("#ius-param-data").val();
    if(!strUtil.isNull(otherParam)){
        if('&'!=otherParam.charAt(0)){
            otherParam="&"+otherParam;
		}
	}
    var index_load = layer.load(2);
    $.ajax({
        type:reqType, url:reqUrl,dataType:'json',
        data:$("#iusCheckForm").serialize()+otherParam,
        success: function(myData){
            console.log(myData);
            $("#ius-request-result").val(JSON.stringify(myData));
            layer.close(index_load);
        },
        error:function(xhr,textStatus){
            $("#ius-request-result").val(textStatus+"："+JSON.stringify(xhr));
            layer.close(index_load);
        }

    });
}
//给模态窗口内form表单内的所有支持必填项的元素注入校验
$(".modal").on('shown.bs.modal', function () {
    $(this).find("form").each(function () {
        var formId = $(this).attr("id");
        if (!strUtil.isNull(formId)) {
            formId = "#" + formId;
            setValidate(formId);//定义add表单验证属性
            mytools.cleanValidate(formId);//清空上次校验规则提示
        }
    });
});
//1.定义校验规则-定义
function setValidate(id) {
    $(id).each(function () {
        $(this).bootstrapValidator({
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            }, /** 以下需要结合实际业务清空补充个表单元素的验证规则 **/
            fields: {
                /** 可自定义新增验证规则
                 "uctUser.userEname":{
								validators: {
								regexp: {
								regexp: /^[0-9]+$/,
								message: '只能是数字'
								}
								}
								}
                 **/
            }
        });
    });
}
/**
var loginWin=null;
function showObjNameTable(){
    loginWin = layer.open({
        type: 2,
        title:"选择接口类型",
        shadeClose: false,
        shade: 0.6,
        area: ['86%', '86%'],
        offset: '20px',
        content: "${page_admin}/project/objName-table-pop-ius?objNameStr="+strUtil.doNull(thisObjNameAll,"")+"&sysEname="+defSysEname //iframe的url
    });
}
var tableObjNameMap = {};
function preObjTableCallBack(objMap){
    console.log(objMap);
    tableObjNameMap = objMap;
    layer.close(loginWin);
    var len  = Object.keys(tableObjNameMap).length;
    var modelTypsStrs = "",formNameStrs = "",formNameBatchStrs = "",pageNameStrs = "";
    for(var key in tableObjNameMap){
        var obj = tableObjNameMap[key];
        modelTypsStrs+=obj.tableObjName+",";
        pageNameStrs=obj.tableName;//以最后选择项为准
        formNameStrs=obj.formName;//以最后选择项为准
    }
    if(!strUtil.isNull(modelTypsStrs)){
        modelTypsStrs=modelTypsStrs.substring(0,modelTypsStrs.length-1);
	}
//    if(!strUtil.isNull(tableNameStr)){
//        tableNameStr=tableNameStr.substring(0,tableNameStr.length-1);
//    }
    $("#submitForm_modelTypes").val(modelTypsStrs);


    if(strUtil.isNull($("#formName").val())){
        $("#formName").val(formNameStrs);
	}
    if(strUtil.isNull($("#pageName").val())){
        pageNameStrs+=formNameStrs.replace(/Form/g, "");
        if(len>1){
            pageNameStrs+=len;
        }
        pageNameStrs=pageNameStrs.replace(/_/g, "-");
        $("#pageName").val(pageNameStrs.toLowerCase());
    }

    loadResultName();

}

**/
function showMonacoPage(id){
    var file_url ="${ctx}/sendPage/plateform/admin/project/sysParamManager-monaco?id="+id+"&sysEname="+defSysEname+"&f="+new Date().getTime();
    loginWin = layer.open({
        type: 2,
        title:"系统["+defSysEname+"]接口增加/修改",
        shadeClose: true,
        shade: false,
        maxmin: true, //开启最大化最小化按钮
        area: ['80%', '90%'],
        content: file_url
    });
}

function preMonacoCallBack() {
    layer.close(loginWin);
    refresh();
}

//判断是否第一次进入，启用步骤引导提示
function initGuideIntroJs() {
    if(strUtil.isNull(strUtil.getLocalStorage("_iussoft_intro_project_parammanagerlist"))){
        strUtil.setLocalStorage("_iussoft_intro_project_parammanagerlist","T");
        showGuideIntroJs();
    }
}

function createSql(){

    var index_load = layer.load(1, {shade: false});
    $.ajax({
        type:'get',
        url:common_list_url,
        data:$("#"+searchFormId).serialize()+getCurrentPage(common_list_url+"?"+$("#"+searchFormId).serialize(),myPage),
        dataType:'json',
        success: function(myData){
            console.log("createSql-->",myData);
            var sql="";
            var resultData = myData.rows;
			for(var i=0;i<resultData.length;i++)
			{
			    var obj = resultData[i].sysParamManager;
                sql = sql+"insert into sys_param_manager(info_id,page_name,form_name,model_types,relation,rules_name,result_column,evel_name,result_name,search_condition,cache_key,check_column,sys_name,title,boot_order,create_time,create_user,modify_time,modify_user,del_status,sub_sort_id,user_owner) values ";
                sql = sql+"('"+obj.infoId+"','"+obj.pageName+"','"+obj.formName+"','"+obj.modelTypes+"','"+obj.relation+"','"+obj.rulesName+"','"+obj.resultColumn+"','"+obj.evelName+"','"+obj.resultName+"','"+obj.searchCondition+"','"+obj.cacheKey+"','"+obj.checkColumn+"','"+obj.sysName+"','"+obj.title+"','"+obj.bootOrder+"','"+obj.createTime+"','"+obj.createUser+"','"+obj.modifyTime+"','"+obj.modifyUser+"','"+obj.delStatus+"',null,null);<br/><br/>";
            }
            // console.log("createSql-->",sql);
         	layer.close(index_load);
			$("#sqlDiv").html(sql);
            $('#sql_modal').modal('show');


        }
    });
}

</script>
  
    </section>
    <!-- Main end -->  
  </div>
  <!-- /.content-wrapper -->
  <!-- foot start -->
  <%@include file="/common/plateform/foot.jsp" %>
  <!-- foot start -->
</div>    
</body>

</html>
